<template>
    <div>
        <button @click="saveCookie">
            存储cookie
        </button>
        <hr/>

        <button @click="deleteCookie">
            删除cookie
        </button>


        <hr/>
        <button @click="readCookie">
            读取cookie
        </button>

        <p>
            {{readedVal}}
        </p>

    </div>
</template>

<script>
    import Cookies from 'js-cookie'

    export default {
        name: "VueCookieTest",
        data() {
            return {
                readedVal: undefined
            }
        },
        methods: {
            //https://www.jianshu.com/p/031e4b80299b
            saveCookie() {
                Cookies.set('name', 'value123');

            },

            readCookie() {
                this.readedVal = Cookies.get('name');

                console.log('读取所有cookie --结果是一个json对象')
                console.log(Cookies.get());
                console.log('读取json里的name的值')
                console.log(Cookies.get().name);
            },

            deleteCookie() {
                Cookies.remove('name');
            }

        }
    }
</script>

<style scoped>

</style>
